''' 
元组
它是由多个元素用()括起来组成(也可以不需要圆括号)。元素之间用，分割。逗号和圆括号最好都存在
'''

season = ('春天')
print("season的类型是： %s" % type(season))

nums = (1)
print("nums的类型是： %s" % type(nums))

# ()和,组合
season = ('春天',)
print("season的类型是： %s" % type(season))

nums = (1,)
print("nums的类型是： %s" % type(nums))

# , 单独使用 也可以生产元组
season = "春天","夏天","秋天","冬天"
print("season的类型是： %s" % type(season))

''' 
向元组里面添加元素

实际上生产新的元组
'''

season = ("春天","夏天","秋天","冬天")
nums = (1,2,3,4,5,6,7,8,9,10,11,12)
newTuple = season + nums

print("新元组为：%s" % str(newTuple))

print("season 的内存地址：%d" % id(season))
print("nums 的内存地址：%d" % id(nums))
print("newTuple 的内存地址：%d" % id(newTuple))

''' 
查看元组的元素
'''

season = ("春天","夏天","秋天","冬天")
print("一年有四个季节：")
for item in season:
  print(item)

print("索引3的元素是 %s" % str(season[3]))
print(list)
# print("索引3的元素是 %s" % str(season[4]))    # IndexErro: tuple index out of range

print("索引1到索引3的元素是：%s" % str(season[1:4]))

''' 
修改元组的元素
元组不支持修改
'''

# season[2] = "春季"  # 报错  元组不支持修改
print(season)

''' 
删除元组的元素
元组不支持删除
只能整个元素删除
'''

del season
print(season)